namespace CSharpPro._0930;

public class Demo
{
    public void Test1()
    {
        Console.WriteLine("请输入三个整数，用空格分隔：");
        string[] input = Console.ReadLine().Split();
        int x = int.Parse(input[0]);
        int y = int.Parse(input[1]);
        int z = int.Parse(input[2]);
        int temp;
        if (x > y)
        {
            temp = x;
            x = y;
            y = temp;
        }
        if (y > z)
        {
            temp = y;
            y = z;
            z = temp;
        }
        if (x > y)
        {
            temp = x;
            x = y;
            y = temp;
        }
        Console.WriteLine("从小到大排序后的结果为：");
        Console.WriteLine($"{x} {y} {z}");
    }

    public void Test2()
    {
        int sum = 0;
        for (int i = 1; i <= 100; i++)
        {
            if (i % 7 != 0 && i / 10 != 7 && i % 10 != 7)
            {
                Console.WriteLine(i);
                sum += i;
            }
        }
        Console.WriteLine(sum);
    }

    public void Test3()
    {
        for (int i = 1; i <= 9; i++)
        {
            for (int j = 1; j <= i; j++)
            {
                Console.Write($"{j}×{i}={i * j}\t");
            }
            Console.WriteLine();
        }
    }

    public void Test4()
    {
        for (int i = 1; i <= 1000; i++)
        {
            int sum = 0;
            for (int j = 1; j < i; j++)
            {
                if (i % j == 0)
                {
                    sum += j;
                }
            }
            if (i == sum)
            {
                Console.WriteLine(i);
            }
        }
    }

    public void Test5()
    {
        Console.WriteLine("请输入一个正整数:");
        string input = Console.ReadLine();
        int num=int.Parse(input);
        int n = num;
        int digit = 0;
        do
        {
            digit++;
            num /= 10;
        } while (num!=0);
        Console.WriteLine(digit);
        while (n!= 0)
        {
            Console.WriteLine(n%10);
            n /= 10;
        }
    }

    public void Test6()
    {
        int n;
        bool isSuccess;
        do
        {
            Console.Write("请输入菱形的行数（奇数）：");
            string input = Console.ReadLine();
            isSuccess = int.TryParse(input, out n);

            if (!isSuccess || n <= 0 || n % 2 == 0)
            {
                Console.WriteLine("输入有误，请重新输入一个正奇数。");
                isSuccess = false;
            }
        } while (!isSuccess);
        for (int i = 1; i <= n / 2 + 1; i++)
        {
            for (int j = 1; j <= (n / 2 + 1) - i; j++)
            {
                Console.Write(" ");
            }
            for (int k = 1; k <= 2 * i - 1; k++)
            {
                Console.Write("*");
            }
            Console.WriteLine();
        }
        for (int i = n / 2; i >= 1; i--)
        {
            for (int j = 1; j <= (n / 2 + 1) - i; j++)
            {
                Console.Write(" ");
            }
            for (int k = 1; k <= 2 * i - 1; k++)
            {
                Console.Write("*");
            }
            Console.WriteLine();
        }
    }
    
    
}